//
//  XHPicView.m
//  BSNoAnswer
//
//  Created by Tiffany宝 on 16/5/20.
//  Copyright © 2016年 Tiffany. All rights reserved.
//

#import "XHPicView.h"
#import "XHTopicModel.h"

@interface XHPicView ()
@property (weak, nonatomic) IBOutlet UIImageView *iv_gif;
@property (weak, nonatomic) IBOutlet UIImageView *iv_backgroundImage;
@property (weak, nonatomic) IBOutlet UIButton *btn_showBigButton;

@end

@implementation XHPicView

+(instancetype)loadPicView{
    
    return [[NSBundle mainBundle]loadNibNamed:NSStringFromClass(self) owner:nil options:nil].lastObject;
}

-(void)setTopics:(XHTopicModel *)topics{
    
    _topics = topics;
    
    [self.iv_backgroundImage sd_setImageWithURL:[NSURL URLWithString:topics.largeImage]];
    self.iv_backgroundImage.contentMode = UIViewContentModeScaleAspectFill;
    self.iv_backgroundImage.clipsToBounds = YES;
    
    //判断点击放大图片按钮是否隐藏
    if (topics.type == XHTopicViewTypePicture) {
        
        self.btn_showBigButton.hidden = !topics.isBigImage;
    }
    
    //判断gif是否隐藏
    // pathExtension 属性可以直接拿到字符串的后缀
    NSString *picSuffix = topics.largeImage.pathExtension;
    if ([picSuffix isEqualToString:@"gif"]) {
        self.iv_gif.hidden = NO;
    }else{
        self.iv_gif.hidden = YES;
    }
//    XHLog(@"%@",picSuffix);
}

@end
